
/*
 * Copyright 2002-2021 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/*
 *版权所有2002-2021原作者。
 *
 *根据Apache许可证2.0版（“许可证”）许可；
 *除非符合许可证的规定，否则您不得使用此文件。
 *您可以在以下网址获取许可证副本
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 *除非适用法律要求或书面同意，否则软件
 *根据许可证分发是在“按原样”的基础上分发的，
 *无任何明示或暗示的保证或条件。
 *有关管理权限的特定语言，请参阅许可证
 *许可证下的限制。
 */

package org.springframework.context.event;

import java.util.function.Predicate;

import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.core.ResolvableType;
import org.springframework.lang.Nullable;

/**
 * Interface to be implemented by objects that can manage a number of
 * {@link ApplicationListener} objects and publish events to them.
 *
 * <p>An {@link org.springframework.context.ApplicationEventPublisher}, typically
 * a Spring {@link org.springframework.context.ApplicationContext}, can use an
 * {@code ApplicationEventMulticaster} as a delegate for actually publishing events.
 *
 * @author Rod Johnson
 * @author Juergen Hoeller
 * @author Stephane Nicoll
 * @see ApplicationListener
 */
/**
 *由可以管理多个
 *｛@link ApplicationListener｝对象并向其发布事件。
 *
 *<p>一个｛@link org.springframework.context.ApplicationEventPublisher｝，通常为
 *Spring｛@link org.springframework.context.ApplicationContext｝，可以使用
 *｛@code ApplicationEventMulticaster｝作为实际发布事件的委托。
 *
 *@作者罗德·约翰逊
 *@作者Juergen Hoeller
 *@作者Stephane Nicoll
 *@请参阅ApplicationListener
 */
public interface ApplicationEventMulticaster {

	/**
	 * Add a listener to be notified of all events.
	 * @param listener the listener to add
	 * @see #removeApplicationListener(ApplicationListener)
	 * @see #removeApplicationListeners(Predicate)
	 */
	/**
	 *添加要通知所有事件的侦听器。
	 *@param listener要添加的监听器
	 *@请参阅#removeApplicationListener（ApplicationListener）
	 *@see#removeApplicationListeners（谓词）
	 */
	void addApplicationListener(ApplicationListener<?> listener);

	/**
	 * Add a listener bean to be notified of all events.
	 * @param listenerBeanName the name of the listener bean to add
	 * @see #removeApplicationListenerBean(String)
	 * @see #removeApplicationListenerBeans(Predicate)
	 */
	/**
	 *添加一个侦听器bean以获得所有事件的通知。
	 *@param listenerBeanName要添加的侦听器bean的名称
	 *@see#removeApplicationListenerBean（字符串）
	 *@参见#removeApplicationListenerBeans（谓词）
	 */
	void addApplicationListenerBean(String listenerBeanName);

	/**
	 * Remove a listener from the notification list.
	 * @param listener the listener to remove
	 * @see #addApplicationListener(ApplicationListener)
	 * @see #removeApplicationListeners(Predicate)
	 */
	/**
	 *从通知列表中删除侦听器。
	 *@param listener要删除的侦听器
	 *@见#addApplicationListener（ApplicationListener）
	 *@see#removeApplicationListeners（谓词）
	 */
	void removeApplicationListener(ApplicationListener<?> listener);

	/**
	 * Remove a listener bean from the notification list.
	 * @param listenerBeanName the name of the listener bean to remove
	 * @see #addApplicationListenerBean(String)
	 * @see #removeApplicationListenerBeans(Predicate)
	 */
	/**
	 *从通知列表中删除一个侦听器bean。
	 *@param listenerBeanName要删除的侦听器bean的名称
	 *@see#addApplicationListenerBean（字符串）
	 *@参见#removeApplicationListenerBeans（谓词）
	 */
	void removeApplicationListenerBean(String listenerBeanName);

	/**
	 * Remove all matching listeners from the set of registered
	 * {@code ApplicationListener} instances (which includes adapter classes
	 * such as {@link ApplicationListenerMethodAdapter}, e.g. for annotated
	 * {@link EventListener} methods).
	 * <p>Note: This just applies to instance registrations, not to listeners
	 * registered by bean name.
	 * @param predicate the predicate to identify listener instances to remove,
	 * e.g. checking {@link SmartApplicationListener#getListenerId()}
	 * @since 5.3.5
	 * @see #addApplicationListener(ApplicationListener)
	 * @see #removeApplicationListener(ApplicationListener)
	 */
	/**
	 *从已注册的集合中删除所有匹配的侦听器
	 *｛@code ApplicationListener｝实例（其中包括适配器类
	 *例如｛@link ApplicationListenerMethodAdapter｝，例如用于带注释的
	 *｛@link EventListener｝方法）。
	 *＜p＞注意：这只适用于实例注册，而不适用于侦听器
	 *通过bean名称注册。
	 *@param谓词用于标识要删除的侦听器实例的谓词，
	 *例如，检查｛@link SmartApplicationListener#getListenerId（）｝
	 *@自5.3.5起
	 *@见#addApplicationListener（ApplicationListener）
	 *@请参阅#removeApplicationListener（ApplicationListener）
	 */
	void removeApplicationListeners(Predicate<ApplicationListener<?>> predicate);

	/**
	 * Remove all matching listener beans from the set of registered
	 * listener bean names (referring to bean classes which in turn
	 * implement the {@link ApplicationListener} interface directly).
	 * <p>Note: This just applies to bean name registrations, not to
	 * programmatically registered {@code ApplicationListener} instances.
	 * @param predicate the predicate to identify listener bean names to remove
	 * @since 5.3.5
	 * @see #addApplicationListenerBean(String)
	 * @see #removeApplicationListenerBean(String)
	 */
	/**
	 *从已注册的
	 *监听器bean名称（指的是bean类
	 *直接实现{@link ApplicationListener}接口）。
	 *＜p＞注意：这只适用于bean名称注册，而不适用于
	 *以编程方式注册的｛@code ApplicationListener｝实例。
	 *@param谓词用于标识要删除的侦听器bean名称的谓词
	 *@自5.3.5起
	 *@see#addApplicationListenerBean（字符串）
	 *@see#removeApplicationListenerBean（字符串）
	 */
	void removeApplicationListenerBeans(Predicate<String> predicate);

	/**
	 * Remove all listeners registered with this multicaster.
	 * <p>After a remove call, the multicaster will perform no action
	 * on event notification until new listeners are registered.
	 * @see #removeApplicationListeners(Predicate)
	 */
	/**
	 *删除所有注册到此多播主机的侦听器。
	 *<p>删除调用后，多播主机将不执行任何操作
	 *直到注册了新的侦听器。
	 *@see#removeApplicationListeners（谓词）
	 */
	void removeAllListeners();

	/**
	 * Multicast the given application event to appropriate listeners.
	 * <p>Consider using {@link #multicastEvent(ApplicationEvent, ResolvableType)}
	 * if possible as it provides better support for generics-based events.
	 * @param event the event to multicast
	 */
	/**
	 *将给定的应用程序事件多播到适当的侦听器。
	 *<p>考虑使用{@link#multicastEvent（ApplicationEvent，ResolutibleType）}
	 *如果可能的话，因为它为基于泛型的事件提供了更好的支持。
	 *@param event要多播的事件
	 */
	void multicastEvent(ApplicationEvent event);

	/**
	 * Multicast the given application event to appropriate listeners.
	 * <p>If the {@code eventType} is {@code null}, a default type is built
	 * based on the {@code event} instance.
	 * @param event the event to multicast
	 * @param eventType the type of event (can be {@code null})
	 * @since 4.2
	 */
	/**
	 *将给定的应用程序事件多播到适当的侦听器。
	 *<p>如果｛@code eventType｝为｛@code-null｝，则会生成默认类型
	 *基于{@code event}实例。
	 *@param event要多播的事件
	 *@param eventType事件类型（可以是｛@code null｝）
	 *@自4.2起
	 */
	void multicastEvent(ApplicationEvent event, @Nullable ResolvableType eventType);

}
